# Include the directory itself as a path to include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Add requirements for external libraries
find_package( SDL REQUIRED )
find_package( Lua51 REQUIRED )
include_directories( ${SDL_INCLUDE_DIR} ${LUA_INCLUDE_DIR} )

# Create a variable containing all .cpp files
file( GLOB game_SOURCES *.cpp )

# Create a variable containing all .h files
file( GLOB game_HEADERS *.h )

# Generate rules to copy over lua files as needed
file( GLOB game_LUA_SRCS *.lua )
copy_if_different(
        "" "${EXECUTABLE_OUTPUT_PATH}/game"
        "${game_LUA_SRCS}" game_LUA_TGTS "Game Lua"
)

# Create a library for this module
add_executable( main ${game_SOURCES} ${game_HEADERS} ${game_LUA_TGTS} )

# Set up other dependencies
target_link_libraries( main core console pl_horde3d pl_revel pl_sdl )
target_link_libraries( main ${CMAKE_DL_LIBS} )
target_link_libraries( main ${LUA_LIBRARIES} )
target_link_libraries( main ${SDL_LIBRARY} )

# Set up installation targets
install( TARGETS main DESTINATION bin )
install( FILES ${game_LUA_TGTS} DESTINATION bin )
